/**
 * Licensed Materials - Property of IBM
 * (c) Copyright IBM Corporation 2008. All Rights Reserved.
 * 
 * Note to U.S. Government Users Restricted Rights:
 * Use, duplication or disclosure restricted by GSA ADP Schedule
 * Contract with IBM Corp.
 *
 * $Id$
 */
package it.uniba.di.collab.jazzfeed.common.model.impl;

import com.ibm.team.repository.common.model.impl.SimpleItemImpl;

import it.uniba.di.collab.jazzfeed.common.model.JazzfeedPackage;
import it.uniba.di.collab.jazzfeed.common.model.User;
import it.uniba.di.collab.jazzfeed.common.model.UserHandle;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>User</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link it.uniba.di.collab.jazzfeed.common.model.impl.UserImpl#getLogin <em>Login</em>}</li>
 *   <li>{@link it.uniba.di.collab.jazzfeed.common.model.impl.UserImpl#getPassword <em>Password</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class UserImpl extends SimpleItemImpl implements User {
	/**
	 * A set of bit flags representing the values of boolean attributes and whether unsettable features have been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected int ALL_FLAGS = 0;

	/**
	 * The default value of the '{@link #getLogin() <em>Login</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLogin()
	 * @generated
	 * @ordered
	 */
	protected static final String LOGIN_EDEFAULT = "jazzfeed"; //$NON-NLS-1$

	/**
	 * The cached value of the '{@link #getLogin() <em>Login</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLogin()
	 * @generated
	 * @ordered
	 */
	protected String login = LOGIN_EDEFAULT;

	/**
	 * The flag representing whether the Login attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected static final int LOGIN_ESETFLAG = 1 << 10;

	/**
	 * The default value of the '{@link #getPassword() <em>Password</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPassword()
	 * @generated
	 * @ordered
	 */
	protected static final String PASSWORD_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getPassword() <em>Password</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPassword()
	 * @generated
	 * @ordered
	 */
	protected String password = PASSWORD_EDEFAULT;

	/**
	 * The flag representing whether the Password attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected static final int PASSWORD_ESETFLAG = 1 << 11;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	private static final int EOFFSET_CORRECTION = JazzfeedPackage.Literals.USER
			.getFeatureID(JazzfeedPackage.Literals.USER__LOGIN)
			- JazzfeedPackage.USER__LOGIN;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected UserImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return JazzfeedPackage.Literals.USER;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getLogin() {
		return login;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLogin(String newLogin) {
		String oldLogin = login;
		login = newLogin;
		boolean oldLoginESet = (ALL_FLAGS & LOGIN_ESETFLAG) != 0;
		ALL_FLAGS |= LOGIN_ESETFLAG;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					JazzfeedPackage.USER__LOGIN + EOFFSET_CORRECTION, oldLogin,
					login, !oldLoginESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetLogin() {
		String oldLogin = login;
		boolean oldLoginESet = (ALL_FLAGS & LOGIN_ESETFLAG) != 0;
		login = LOGIN_EDEFAULT;
		ALL_FLAGS &= ~LOGIN_ESETFLAG;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET,
					JazzfeedPackage.USER__LOGIN + EOFFSET_CORRECTION, oldLogin,
					LOGIN_EDEFAULT, oldLoginESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetLogin() {
		return (ALL_FLAGS & LOGIN_ESETFLAG) != 0;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPassword(String newPassword) {
		String oldPassword = password;
		password = newPassword;
		boolean oldPasswordESet = (ALL_FLAGS & PASSWORD_ESETFLAG) != 0;
		ALL_FLAGS |= PASSWORD_ESETFLAG;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					JazzfeedPackage.USER__PASSWORD + EOFFSET_CORRECTION,
					oldPassword, password, !oldPasswordESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetPassword() {
		String oldPassword = password;
		boolean oldPasswordESet = (ALL_FLAGS & PASSWORD_ESETFLAG) != 0;
		password = PASSWORD_EDEFAULT;
		ALL_FLAGS &= ~PASSWORD_ESETFLAG;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET,
					JazzfeedPackage.USER__PASSWORD + EOFFSET_CORRECTION,
					oldPassword, PASSWORD_EDEFAULT, oldPasswordESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetPassword() {
		return (ALL_FLAGS & PASSWORD_ESETFLAG) != 0;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID - EOFFSET_CORRECTION) {
		case JazzfeedPackage.USER__LOGIN:
			return getLogin();
		case JazzfeedPackage.USER__PASSWORD:
			return getPassword();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID - EOFFSET_CORRECTION) {
		case JazzfeedPackage.USER__LOGIN:
			setLogin((String) newValue);
			return;
		case JazzfeedPackage.USER__PASSWORD:
			setPassword((String) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID - EOFFSET_CORRECTION) {
		case JazzfeedPackage.USER__LOGIN:
			unsetLogin();
			return;
		case JazzfeedPackage.USER__PASSWORD:
			unsetPassword();
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID - EOFFSET_CORRECTION) {
		case JazzfeedPackage.USER__LOGIN:
			return isSetLogin();
		case JazzfeedPackage.USER__PASSWORD:
			return isSetPassword();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) {
		if (baseClass == UserHandle.class) {
			switch (baseFeatureID) {
			default:
				return -1;
			}
		}
		if (baseClass == User.class) {
			switch (baseFeatureID - EOFFSET_CORRECTION) {
			case JazzfeedPackage.USER__LOGIN:
				return JazzfeedPackage.USER__LOGIN + EOFFSET_CORRECTION;
			case JazzfeedPackage.USER__PASSWORD:
				return JazzfeedPackage.USER__PASSWORD + EOFFSET_CORRECTION;
			default:
				return -1;
			}
		}
		return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String toString() {
		if (eIsProxy())
			return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (login: "); //$NON-NLS-1$
		if ((ALL_FLAGS & LOGIN_ESETFLAG) != 0)
			result.append(login);
		else
			result.append("<unset>"); //$NON-NLS-1$
		result.append(", password: "); //$NON-NLS-1$
		if ((ALL_FLAGS & PASSWORD_ESETFLAG) != 0)
			result.append(password);
		else
			result.append("<unset>"); //$NON-NLS-1$
		result.append(')');
		return result.toString();
	}

} //UserImpl
